﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerManager : MonoBehaviour ,IGameManager{

    public ManagerStatus status { get; private set; }
    public int health { get; private set; }
    public int maxHealth { get; private set; }

    private NetworkService _network;

	// Use this for initialization
	void Start () {
		
	}
	
	// Update is called once per frame
	void Update () {
		
	}

    public void Startup(NetworkService service)
    {
        Debug.Log("Player managerstarting...");

        UpdateData(50,100);

        health = 50;
        maxHealth = 100;

        status = ManagerStatus.Started;
    }

    public void ChangeHealth(int value)
    {
        health += value;
        if (health > maxHealth)
        {
            health = maxHealth;
        }else if (health < 0)
        {
            health = 0;
        }

        Messenger.Broadcast(GameEvent.HEALTH_UPDATED);

        Debug.Log("Health:" + health + "/" + maxHealth);
    }

    public void UpdateData(int health, int maxHealth)
    {
        this.health = health;
        this.maxHealth = maxHealth;
    }

    public void Respawn()
    {
        UpdateData(50,100);
    }
}
